package cn.leelei.mybatis.dao;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import cn.leelei.mybatis.dao.impl.UserDaoImpl;
import cn.leelei.mybatis.entity.User;
/**
 * 实现类方式实现增删改查
 * @author Administrator
 *
 */

public class UserDao implements UserDaoImpl {

private SqlSessionFactory Factory;
	
	public void setFactory(SqlSessionFactory factory) {
		Factory = factory;
	}
	
	public void Seve(User user) {
		SqlSession session = Factory.openSession();
		
		session.insert("test.save",user);
		session.commit();
		session.close();
		
	}

	public void Update(User user) {
		// TODO Auto-generated method stub
		
	}
	public void DeleteFindById(Integer id) {
		SqlSession session = Factory.openSession();
		session.delete("test.fuzzy",id);
		session.commit();
		session.close();
		
	}

	public User FindByID(Integer id) {
		SqlSession session = Factory.openSession();
		User user = session.selectOne("test.save",id);
		session.commit();
		session.close();
		return user;
		
	}

	
}
